
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.text.DecimalFormat;
import java.util.Scanner;

public class TestMain {
    public static void main(String[] args) throws UnsupportedEncodingException {
        Scanner input = new Scanner(System.in,"UTF-8");
        PrintStream ps=new PrintStream(System.out,true,"UTF-8");
        ps.println("选择图形：1.圆形 2 长方形 3 正方形");
        int chooseNum = input.nextInt();
        switch (chooseNum){
            case 1:
                ps.print("输入圆形半径r:");
                double i = input.nextDouble();
                Graphical cicle = new Cicle(i);
                break;
            case 2:
                ps.print("输入长方形长和宽(用英文逗号分隔):");
                String cc=input.next();
                Graphical rectangle = new Rectangle(cc);
                break;
            case 3:
                ps.print("输入正方形边长:");
                double v = input.nextDouble();
                Graphical square = new Square(v);
                break;
            default:
                break;
        }
    }
}
class Graphical{
    private double area;
    //周长
    private double perimeter;
    //1.圆形 2 长方形 3 正方形
    private Integer shape;

    public double getArea() {
        return area;
    }

    public void setArea(double area) {
        this.area = area;
    }

    public double getPerimeter() {
        return perimeter;
    }

    public void setPerimeter(double perimeter) {
        this.perimeter = perimeter;
    }

    public Integer getShape() {
        return shape;
    }

    public void setShape(Integer shape) {
        this.shape = shape;
    }

    public Graphical(double area, double perimeter, Integer shape) {
        this.area = area;
        this.perimeter = perimeter;
        this.shape = shape;
    }

    public Graphical() {
    }
}
class Cicle extends Graphical{
    PrintStream ps=new PrintStream(System.out,true,"UTF-8");
    Scanner input = new Scanner(System.in,"UTF-8");
    private double halfLength;

    public double getHalfLength() {
        return halfLength;
    }

    public void setHalfLength(double halfLength) {
        this.halfLength = halfLength;
    }

    public Cicle(double area, double perimeter, Integer shape, double halfLength) throws UnsupportedEncodingException {
        super(area, perimeter, shape);
        this.halfLength = halfLength;
    }

    public Cicle(double halfLength) throws UnsupportedEncodingException {
        this.halfLength = halfLength;
        ps.print("圆形面积:"+new DecimalFormat("#.00").format(calArea(halfLength))+",周长:"+new DecimalFormat("#.00").format(zhouchang(halfLength)));
    }

    public double calArea(double r){
        return Math.PI*r*r;
    }

    public double zhouchang(double r){
        return 2*Math.PI*r;
    }

}
class Rectangle extends Graphical{
    PrintStream ps=new PrintStream(System.out,true,"UTF-8");
    private double length;
    private double width;

    Rectangle() throws UnsupportedEncodingException {
    }

    public Rectangle(String cc) throws UnsupportedEncodingException {
        String[] split = cc.split(",");
        ps.print("长方形面积:"+new DecimalFormat("#.00").format(calArea(Double.parseDouble(split[0]),Double.parseDouble(split[1])))+",周长:"+new DecimalFormat("#.00").format(calZhouchang(Double.parseDouble(split[0]),Double.parseDouble(split[1]))));
    }

    public double calArea(double length,double width){
        return length*width;
    }

    public double calZhouchang(double length,double width){
        return 2*(length+width);
    }

    public double getLength() {
        return length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public double getWidth() {
        return width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

}
class Square extends Graphical{
    PrintStream ps=new PrintStream(System.out,true,"UTF-8");
    private double sideLength;

    Square(double v) throws UnsupportedEncodingException {
        ps.print("正方形面积:"+new DecimalFormat("#.00").format(calArea(v))+",周长:"+new DecimalFormat("#.00").format(calZhouchang(v)));
    }
    public double calArea(double v){
        return v*v;
    }

    public double calZhouchang(double v){
        return 4*v;
    }

    public double getSideLength() {
        return sideLength;
    }

    public void setSideLength(double sideLength) {
        this.sideLength = sideLength;
    }
}
